﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;

namespace QuickExcel
{
    public partial class toggleSetting : Form
    {
        public toggleSetting()
        {
            InitializeComponent();
            chkPageBreaks.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ActiveSheet.DisplayPageBreaks);
            chkVerticalScroll.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ActiveWindow.DisplayVerticalScrollBar);
            chkHorizontalScroll.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ActiveWindow.DisplayHorizontalScrollBar);
            chkDisplayZero.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ActiveWindow.DisplayZeros);
            chkRowsColsHeading.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ActiveWindow.DisplayHeadings);
            chkSheetTabs.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ActiveWindow.DisplayWorkbookTabs);
            chkStatusBar.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.DisplayStatusBar);
            chkWindowsTaskbar.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ShowWindowsInTaskbar);
            chkFormulaBar.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.DisplayFormulaBar);
            chkFullScreen.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.DisplayFullScreen);
            chkGridlines.Checked = Convert.ToBoolean(Globals.ThisAddIn.Application.ActiveWindow.DisplayGridlines);

        }

        private void cmdDefaults_Click(object sender, EventArgs e)
        {
            chkStatusBar.Checked = true;
            chkFormulaBar.Checked = true;
            chkFullScreen.Checked = false;
            chkWindowsTaskbar.Checked = true;
            chkGridlines.Checked = true;
            chkRowsColsHeading.Checked = true;
            chkVerticalScroll.Checked = true;
            chkHorizontalScroll.Checked = true;
            chkFormatView.Checked = false;
            chkSheetTabs.Checked = true;
            chkDisplayZero.Checked = true;
            chkPageBreaks.Checked = false;
        }

        private void cmdClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cmdApply_Click(object sender, EventArgs e)
        {
            Globals.ThisAddIn.Application.ActiveSheet.DisplayPageBreaks=chkPageBreaks.Enabled ;
            Globals.ThisAddIn.Application.ActiveWindow.DisplayVerticalScrollBar=chkVerticalScroll.Enabled;
            Globals.ThisAddIn.Application.ActiveWindow.DisplayHorizontalScrollBar=chkHorizontalScroll.Enabled;
            Globals.ThisAddIn.Application.ActiveWindow.DisplayZeros=chkDisplayZero.Enabled;
            Globals.ThisAddIn.Application.ActiveWindow.DisplayHeadings=chkRowsColsHeading.Enabled;
            Globals.ThisAddIn.Application.ActiveWindow.DisplayWorkbookTabs=chkSheetTabs.Enabled;
            Globals.ThisAddIn.Application.DisplayStatusBar=chkStatusBar.Enabled;
            Globals.ThisAddIn.Application.ShowWindowsInTaskbar=chkWindowsTaskbar.Enabled;
            Globals.ThisAddIn.Application.DisplayFormulaBar=chkFormulaBar.Enabled;
            Globals.ThisAddIn.Application.DisplayFullScreen=chkFullScreen.Enabled;
            Globals.ThisAddIn.Application.ActiveWindow.DisplayGridlines=chkGridlines.Enabled;
            this.Close();
        }
    }
}
